home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / MEdit_1.5.cpt / Macros .mcr < prev    next >
Text File  |  1986-11-07  |  6KB  |  318 lines

  1. **************************************************************************
  2. * This macro file is provided as a collection of useful example macros   *
  3. * You need MComp version 1.0D4 or later to compile this file.            *
  4. * Written           : 05.01.86 Matthias Aebi                             *
  5. * Last modification : 19.07.86 Matthias Aebi                             *
  6. **************************************************************************
  7.  
  8. * 1
  9. * This macro can be used to get irregulary spaced tabs.
  10. * Write a dot in the first line of the window for every tab stop
  11. * that you would like to use.
  12. "Tabs" {
  13.     Push;
  14.     Select(0,C.);
  15.     Push;
  16.     Find(".");
  17.     Select(0,C[ | 0,C.);
  18.     Copy;
  19.     Drop;
  20.     Pop;
  21.     Paste;
  22.     Insert(" ");
  23. };
  24.  
  25. * For use together with the following macros
  26. * 2
  27. "Save current Position/P" {
  28.     push;
  29. };
  30.  
  31. * 3
  32. * Jumps back to the last saved position with macro 2
  33. * the stack can hold the last eight positions
  34. "Back to Position/B" {
  35.     select(L[,C[)!;
  36.     pop;
  37. };
  38.  
  39. * 4
  40. * Moves the current selection to the position / selection
  41. * previously saved with macro 2
  42. "Move selection/M" {
  43.     cut;
  44.     pop;
  45.     paste!;
  46. };
  47.  
  48. * 5
  49. * Copies the current selection to the position / selection
  50. * previously saved with macro 2
  51. "Copy selection/K" {
  52.     copy;
  53.     pop;
  54.     paste!;
  55. };
  56.  
  57. * 6
  58. * Draw a line in the menu
  59. "-" {};
  60.  
  61. * 7
  62. * Jump to bottom of file (last line of last section)
  63. "Bottom" {
  64.     Sect(S$);
  65.     Select(L$,C$)!;
  66. };
  67.  
  68. * 8
  69. * Jump to top of file
  70. "Top" {
  71.     SECT(0);
  72.     SELECT(0,0)!;
  73. };
  74.  
  75. * 9
  76. * Select all lines in the current section
  77. "Select all" {
  78.     SELECT(0,0|L$,C$);
  79. };
  80.  
  81. * 10
  82. * Move all lines in the current selection four positions to the left
  83. * by deleting the leftmost characters. do nothing for empty lines.
  84. "Move selection left/L" {
  85.     PUSH;
  86.     WHILE L. < L] {
  87.         SELECT(L.,0|L.,4);
  88.         CLEAR;
  89.         SELECT(L.+1,0)!;
  90.     };
  91.     SELECT(L[,0|L],0);
  92.     DROP;
  93. };
  94.  
  95. * 11
  96. * Move all lines in the current selection to the right by inserting
  97. * a tab. do nothing for empty lines.
  98. "Move selection right/R" {
  99.     PUSH;
  100.     WHILE L. < L] {
  101.         SELECT(L.,0);
  102.         IF NOT C$ = 0
  103.             INSERT("\t");
  104.         SELECT(L.+1,0)!;
  105.     };
  106.     SELECT(L[,0|L],0);
  107.     DROP;
  108. };
  109.  
  110. * 12
  111. * Ask for a line number to jump to and do it
  112. "Jump to Line/J" {
  113.     prompt("Goto Line",#0);
  114.     select(#0-1,0|#0-1,C$)!;
  115. };
  116.  
  117. * 13
  118. * Ask for a section number to jump to and do it
  119. "Jump to Section/S" {
  120.     prompt("Goto Section",#0);
  121.     sect(#0);
  122.     select(0,0)!;
  123. };
  124.  
  125. * 14
  126. * Replace the shortcut to the left of the cursor position with
  127. * the appropriate string. To define shortcuts list them in a
  128. * second window just behind the current text window. Each shortcut
  129. * should be followed by the string by which it should be replaced.
  130. * Use one line for each shortcut. separate string and shortcut by a blank.
  131. * examples: (Define them without an asterik at the start of the window)
  132. *
  133. * ilm I like Macintosh
  134. * gb Good bye
  135. *
  136. * If you type 'ilm' and then press command-g this will replace
  137. * 'ilm' with 'I like Macintosh'. 'gb' will be replaced by 'Good bye'
  138. "Glossary/G" {
  139.     Select(L.,C<|L.,C.);
  140.     Push;
  141.     Set($0,$S);
  142.  
  143.     Window(1);
  144.     Select(0,0);
  145.  
  146.     If Find($0) {
  147.         Select(L.,C:+1|L.,C$);
  148.         Copy;
  149.         Window(0);
  150.         Pop;
  151.         Paste;
  152.     }
  153.     Else {
  154.         Pop;
  155.         Select(L:,C:);
  156.     };
  157. };
  158.  
  159. * 15
  160. * Find next word and select it.
  161. * If you have a Mac+ or a numeric keypad you may use shift-cursor-right
  162. "Next Word" 266 {
  163.     select(L:,C:+1);
  164.     if C. = C$ AND NOT L. = L$
  165.         select(L.+1,0);
  166.  
  167.     while C> = -1 AND NOT L. = L$
  168.         select(L.+1,0);
  169.  
  170.     select(L.,C>);
  171.     select(L.,C< | L.,C.);
  172. };
  173.  
  174. * 16
  175. * Find previous word and select it.
  176. * If you have a Mac+ or a numeric keypad you may use shift-cursor-left
  177. "Previous Word" 270 {
  178.     select(L.,C.-1);
  179.     if C. = 0
  180.         select(L.-1,C$);
  181.  
  182.     while C< = -1
  183.         select(L.-1,C$);
  184.  
  185.     select(L.,C<);
  186.     select(L.,C. | L.,C>);
  187. };
  188.  
  189. * 17
  190. * Replace all 'real' tabs by blank strings
  191. * this is useful to convert 'Edit'- to 'MEdit'-files
  192. "Replace tabs" {
  193.     SELECT(0,0);
  194.     SECT(0);
  195.     WHILE FIND("\9")
  196.         INSERT("\t");
  197.     BEEP;
  198. };
  199.  
  200. * 18
  201. * Scroll one screen down.
  202. * If you have a Mac+ or a numeric keypad you may use shift-cursor-down
  203. "Page Down/D" 272 {
  204. * get screen height
  205.     Set(#9, L>-L<-1);
  206.     Select(L>+#9,C.)!;
  207. };
  208.  
  209. * 19
  210. * Scroll one screen up.
  211. * If you have a Mac+ or a numeric keypad you may use shift-cursor-up
  212. "Page Up/U" 277 {
  213. * get screen height
  214.     Set(#9, L>-L<-1);
  215.     Select(L<-#9,C.)!;
  216. };
  217.  
  218. * 20
  219. "Append Section" {
  220.     Append;
  221. };
  222.  
  223. * 21
  224. "-" {};
  225.  
  226. * 22
  227. * The numbers define cursor keys on a Mac Plus / num Keypad
  228. "Cursor Up/2" 177 {
  229.     SELECT(L.-1,C.)!;
  230. };
  231.  
  232. * 23
  233. "Cursor Down/A" 172 {
  234.     SELECT(L.+1,C.)!;
  235. };
  236.  
  237. * 24
  238. "Cursor Right/W" 166 {
  239. * The following instruction sets the last accessed line to current line.
  240. * This is necessary to get the correct result from C$ in 'IF C. = C$...'
  241.     SELECT(L.,C.);
  242.     IF C. = C$
  243.         SELECT(L.+1,0)!
  244.     ELSE
  245.         SELECT(L.,C.+1)!;
  246. };
  247.  
  248. * 25
  249. "Cursor Left/Q" 170 {
  250.     IF NOT C. > 0
  251.         SELECT(L.-1,C$)!
  252.     ELSE
  253.         SELECT(L.,C.-1)!;
  254. };
  255.  
  256. * This macro could be used to
  257. * redefinie shift-BS to 'delete to end of line' instead of 'delete right char'
  258. * 251 {
  259. *    Select(L.,C.|L.,C$);
  260. *    Clear;
  261. *};
  262.  
  263. * 26
  264. * TAB:
  265. * inserts blanks to next tab position
  266. 148 {
  267.     INSERT("\t");
  268. };
  269.  
  270. * 27
  271. * shift - TAB:
  272. * deletes characters back to previous tab position
  273. 248 {
  274.     INSERT("\T");
  275. };
  276.  
  277. * 28
  278. * option - TAB:
  279. * insert a 'real' tab
  280. 348 {
  281.     INSERT("\9");
  282. };
  283.  
  284. * 29
  285. * CR:
  286. * insert newline and do autoindent if selected
  287. * NOTE: the key number 236 is correct for a german mac+ keyboard only!
  288. 136 {
  289.     INSERT("\n");
  290. };
  291.  
  292. * 30
  293. * shift - CR:
  294. * insert newline with autoindent flag toggled
  295. * NOTE: the key number 236 is correct for a german mac+ keyboard only!
  296. 236 {
  297.     INSERT("\N");
  298. };
  299.  
  300. * 31
  301. * shift - BS:
  302. * delete right character
  303. 251 {
  304.     INSERT("\B");
  305. };
  306.  
  307. * 32
  308. * option - BS
  309. * swap the to characters just before the current position
  310. 351 {
  311.     SELECT(L.,C.-1|L.,C.);
  312.     CUT;
  313.     SELECT(L.,C.-1);
  314.     PASTE;
  315.     SELECT(L.,C.+1);
  316. }.
  317.  
  318.